<?php
/**
 *	@package WordPress
 *	@subpackage Grid_Focus
 */
get_header();
?>
<div id="filler" class="fix">
	<div id="mainColumn">

		<?php 
		$header_display = '';
		// pull only 'MAIN' messages for frontpage
		if ($catname == 'tag') {
			$current_tag = single_tag_title('', false);
			$header_display = 'Tag: ' . $current_tag;
		}
		
		else if (is_archive()) $header_display = 'Archived: ' . wp_title('', false);

		else if ($catname == 'home') {
			// Which page of the blog are we on?
			$paged = get_query_var('paged');
			query_posts('cat=3&paged='.$paged);
			$header_display = 'Main Posts';
		}
		
		?>

		<h2 class="title"><?php echo $header_display; ?></h2>

		<?
		if (have_posts()) : while (have_posts()) : the_post(); ?>
		<div id="post-<?php the_ID(); ?>" class="post">
			<h2><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
			<div class="postMeta">
				<p class="container-left">
					<span class="author"><?php the_author(); ?></span>
				</p>
				<p class="container">
					<span class="date"><?php the_time('M j, Y'); ?></span>
					<span class="comments"><?php comments_popup_link('0', '1', '%'); ?></span>
				</p>
			</div>
			<div class="entry">
				<?php the_content('Read the rest of this entry &raquo;'); ?>
				
				<div class="comments">
					<?php comments_popup_link('Be the first to comment &raquo;', '1 Comment &raquo;', '% Comments &raquo;'); 
					
/*					$lastcomment = mysql_fetch_assoc(mysql_query('SELECT comment_ID, comment_author FROM wp_comments WHERE comment_post_ID = '.$id.' ORDER BY comment_date DESC LIMIT 1'));
					echo "<!-- id: $lastcomment -->";
					if ($lastcomment) {
						echo ' | Last commented by ' . $lastcomment['comment_author'];
					}*/
					?>
				</div>
			</div>
		</div>
		<?php endwhile; ?>
		<?php else : ?>
		<div class="post">
			<div class="postMeta">
				<p class="container">
					<span class="date">No Matches</span>
				</p>
			</div>
			<h2>No matching results</h2>
			<div class="entry">
				<p>You seem to have found a mis-linked page or search query with no matching results. Please trying your search again. If you feel that you should be staring at something a little more concrete, feel free to email the author of this site or browse the archives.</p>
			</div>
		</div>
		<?php endif; ?>
		<div id="paginateIndex" class="fix">
			<p><span class="left"><?php previous_posts_link('&laquo; Newer') ?></span> <span class="right"><?php next_posts_link('Older &raquo;') ?></span></p>
		</div>
	</div>

	<?php 
	include (TEMPLATEPATH . '/second.column.index.php'); 
	include (TEMPLATEPATH . '/third.column.shared.php'); 
	?>
</div>
<?php get_footer(); ?>